package io;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;

/**
 * 写入到byte数组
 */
public class OutputStreamDemo3 {
    public static void main(String[] args) throws IOException {
        File file=new File("mytest.txt");
        if(!file.exists()){
            file.createNewFile();
        }
        //写入操作
        try(OutputStream outputStream=new FileOutputStream(file)){
            String msg="hello,world";
            outputStream.write(msg.getBytes(StandardCharsets.UTF_8));
            outputStream.flush();

        }
    }
}
